/* 
 * File:   ShaderItem.h
 * Author: ferranferri
 *
 * Created on May 30, 2013, 5:47 PM
 */
#pragma once
#ifndef SHADERITEM_H
#define	SHADERITEM_H

#include "core/core_utils.h"
#include "Log/LogSystem.h"
#include "../internal/engine_constants.h"
#include "ShaderType.h"

namespace z3d{
    class ShaderItem {
        std::string _name;
        std::string* _source;
        std::string _filename;
        GLenum _type;
        GLuint _handle;
        bool _debugState;
        bool _compiled;
        uint32_t _refCount;
        glog::CGlobalLog* _log;
        
        
    public:
        ShaderItem(const std::string& name, const std::string& fileName, GLenum type);
        
        /**
         * Initialize the shader item object. The init process DO NOT load the shader to 
         * the graphic device.
         * @return true if all is OK
         */
        bool init();
        
        bool load();
        
        bool compile();
        
        /**
         * Unloads the shader from the graphic device. If you want to use the shader again, you'll 
         * need to get another handle from opengl. The source code is still here
         * @return if all goes good
         */
        bool unload();
        
        std::string getName() const {
            return _name;
        }

        uint32_t getRefCount() const {
            return _refCount;
        }

        bool isDebugState() const {
            return _debugState;
        }
        
        bool isCompiled() const {
            return _compiled;
        }
            

        GLuint getHandle() const {
            return _handle;
        }

        GLenum getType() const {
            return _type;
        }
        
        virtual ~ShaderItem();
    private:

    };
}
#endif	/* SHADERITEM_H */

